package com.damon.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.damon.WcsSocketRun;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

/**
 * 读取属性文件的工具类
 * @author 风蚕
 *
 */
public class PropertiesUtil {
	static Logger logger = LoggerFactory.getLogger(PropertiesUtil.class);
	static Map<String,String> propertiesMap = new HashMap<>();
	static {
		Properties properties = new Properties();
		InputStream is = WcsSocketRun.class.getResourceAsStream("/properties.properties");
		try {
			properties.load(is);
			//打印配置文件参数
			Set<Entry<Object, Object>> propertiesSet = properties.entrySet();
			propertiesSet.stream().forEach(e -> {
				propertiesMap.put((String) e.getKey(), (String) e.getValue());
			});
		} catch (IOException e) {
			
			logger.error("读取配置文件失败！");
			e.printStackTrace();
		}
	}
	
	public static Map<String, String> getPropertiesMap(){
		return propertiesMap;
	}
}
